# 今日作业
#     ### 必做
#         1 完成课堂案例练习
#         2 完成新浪搜索：http://search.sina.com.cn/
#             需求：输入关键词下载指定页面
#
#     ###　选做
#         案例：樱花动漫：http://www.imomoe.live/search.asp
#             需求：通过关键词搜索下载指定内容
#
#2.
#导模块
import json


from bs4 import BeautifulSoup as bs
import requests

#确定url
from matplotlib.testing.compare import convert

url = 'http://www.imomoe.live/search.asp'
#构造请求头
headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
                      'AppleWebKit/537.36 (KHTML, like Gecko) '
                      'Chrome/96.0.4664.55 Safari/537.36 Edg/96.0.1054.43'}
name=input('输入关键字：')
data={
    'searchword':name.encode('utf8')
}
#发送请求
response=requests.post(url,data=data,headers=headers)

rs = response.content
soup=bs(rs,'html.parser')
value = soup.find_all('h2')
print(value)


# print('{}'.format(value))
# with open(f'{name}.html','wb') as file_build:
#     file_build.write(response.content)